﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TaskCancel.aspx.cs" Inherits="H2.NET.Web.Workflow.Workflow.TaskCancel" %>

<script type="text/javascript">

    function DoTaskCancel() {
        var isMDC;
        var selected = [];
        var $checkboxLi = $(":checkbox[name='ids']", $.pdialog.getCurrent());
        $checkboxLi.each(function () {
            if ($(this).attr("checked") == "checked") {
                selected.push($(this).attr("value"));
                $(this).attr("processname");
                if ($(this).attr("processname") == "store data change" || $(this).attr("processname") == "store deposit receive" || $(this).attr("processname") == "store deposit change" || $(this).attr("processname") == "new store application") {
                    isMDC = true;
                }
            }
        });

        if (selected.length == 0) {
            alertMsg.warn("至少选择一条数据");
            return false;
        }
        if ($('#CancelReason').val() == "" && isMDC) {
            alertMsg.warn("发现有MDC流程被取消实例，请填写原因。");
            return false;
        }


        alertMsg.confirm("确定要取消所选的实例吗？", {
            okCall: function () {
                $.ajax({
                    type: "POST",
                    url: "Workflow/TaskCancel.aspx?action=cancel_selected",
                    data: { ids: selected.join(",") },
                    cache: false,
                    success: function (result) {
                        if (result) {
                            alertMsg.correct("取消实例成功！");
                            $.pdialog.reload("Workflow/TaskCancel.aspx");
                            navTab.reloadFlag("ToDoList"); //刷新待办事项
                        } else {
                            alertMsg.error("取消实例失败！");
                        }
                    },
                    error: function (response) {
                        alertMsg.error(response);
                    }
                });
            }
        });

        return false;
    }



</script>
<div class="pageHeader">
    <div class="searchBar" id="todolist_searchBar">
    <form id="taskCancelForm" onsubmit="return dialogSearch(this);" action='workflow/TaskCancel.aspx' method="post" runat="server">
        <asp:hiddenfield id="hf_type" runat="server"></asp:hiddenfield>
        <asp:hiddenfield id="hf_list_type" runat="server"></asp:hiddenfield>
        <table class="searchContent">
            <tr>
                <td>
                    <%= clsCmm.getTextValue("frm_inbox_txtProcess")%>
                    <asp:dropdownlist id="drpProcess" runat="server" onchange="$('#taskCancelForm', $.pdialog.getCurrent()).submit()"></asp:dropdownlist>
                
                    <%=clsCmm.getTextValue("frm_initiate_txtStep")%>
                    <asp:dropdownlist id="drpStep" runat="server" onchange="$('#taskCancelForm', $.pdialog.getCurrent()).submit()"></asp:dropdownlist>
                
                    <%= clsCmm.getTextValue("frm_inbox_txtIncidentFrom")%>
                    <input type="text" runat="server" id="txtIncidentFrom" size="8" /> 至
                    <input type="text" runat="server" id="txtIncidentTo" size="8" />
                
                    <%=clsCmm.getTextValue("frm_inbox_txtSummary") %>
                    <asp:TextBox ID="tb_Summary" runat="server" Width="194px"></asp:TextBox>
                </td>
            </tr>
        </table>
        <div class="subBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit" onclick="initOrderDir()">
                                <%=clsCmm.getTextValue("frm_inbox_btnSearch")%></button></div>
                    </div>
                </li>
            </ul>
        </div>
        
        <input type="hidden" id="tranStyle" runat="server" />
        </form>
    </div>
</div>

<div class="pageContent">
    <div class="pageFormContent"style="padding: 0px;">
        <table class="table" width="100%"  layouth="145" >
            <thead>
                <tr>
                    <th width="22">
                        <input type="checkbox" group="ids" class="checkboxCtrl">
                    </th>
                    <th width="50" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_monitor")%>
                    </th>
                    <th width="50" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_status")%>
                    </th>
                    <th width="200">
                        <%=clsCmm.getTextValue("frm_inbox_gv_process_name")%>
                    </th>
                    <th width="200">
                        <%=clsCmm.getTextValue("frm_inbox_gv_summary")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_step_name")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_start_time")%>
                    </th>
                    <th width="140" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_applicator")%>
                    </th>
                    <th width="100" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_owner")%>
                    </th>
                    <th width=50" align="center">
                        <%=clsCmm.getTextValue("frm_inbox_gv_incident_no")%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:repeater id="gvInbox" runat="server">
                <ItemTemplate>
                    <tr>
                        <td><input name="ids" value="<%# Eval("taskid") %>" processname="<%# Eval("processname3")%>" type="checkbox"></td>
                        <td><a href="javascript:;" onclick="return openDialog('<%# Eval("processname3")%>', 'workflow/monitor.aspx?TaskID=<%# Eval("taskid") %>', 1000, 600)" target="_blank"><img alt="<%=clsCmm.getTextValue("frm_inbox_img_alt")%>" border="0" src="../Resource/Images/<%# Eval("img_monitor") %>" width="16" height="16"></a></td>
                        <td><img alt="" border="0" src="../Resource/Images/<%# Eval("img_status") %>" width="16" height="16"></td>
                        <td><a href="javascript:;" onclick="<%#Eval("openform")%>" target="_blank"><%# Eval("processname3")%></a></td>
                        <td><a href="javascript:winOpenForm('<%# Eval("openform") %>?TaskID=<%# Eval("taskid") %>','tr_row_<%# Eval("taskid") %>')" target="_blank"><%# Eval("summary")%></a></td>
                        <td><%# Eval("steplabel")%></td>
                        <td><%# Eval("starttime","{0:yyyy-MM-dd HH:mm}")%></td>
                        <td><%# Eval("initiator_name")%></td>
                        <td><%# Eval("taskuser_name")%></td>
                        <td><%#Eval("incident")%></td>
                    </tr> 
                </ItemTemplate>
                
            </asp:repeater>
            </tbody>
        </table>
       
        <table class="formTable"  style="padding: 0px;width:99%">
            <tbody>
                <tr>
                    <th width="20%" >取消实例原因：</th>
                    <td width="80%"><input type="text" id="CancelReason" runat="server" style="width:90%"/></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" onclick="return DoTaskCancel();">
                            取消选中的实例</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            关闭窗口</button></div>
                </div>
            </li>
        </ul>
    </div>
</div>
